import React, { useRef, useEffect } from "react";
import { connect } from "react-redux";
import { Button } from "antd";



export const Home = (props) => {
  const countRef = useRef(0); // {curent: null}
  countRef.current = countRef.current + 1;
  useEffect(()=>{
    const timer = setInterval(()=>{
        console.log(new Date())
    }, 1000);
    console.log(`timer：`, timer)
    return () => {
        clearInterval(timer);
    }
  }, [props.isShow])
//   console.log('boxRef.current)', boxRef.current)
  return (
    <div
    >
      {/* {props.count} */}
      <Button type="primary">
        点我
      </Button>
    </div>
  );
};

const mapStateToProps = (state) => {
  console.log("state-filter", state);
  return {
    count: state.count,
  };
};

const mapDisPatch = (disPatch) => {
  return {
    disPatch,
  };
};

class Parent extends React.Component {
    state= {
        isShow: true
    }
  componentDidMount() {
    this.setState({
        isShow: true,
    });

  }
  render() {
    return <Home isShow={this.state?.isShow}/>;
  }
}

export default Parent;
// export default connect(mapStateToProps, mapDisPatch)(Home)
